/* $Id: Location.java,v 1.9 2007/09/07 06:51:22 gigabass Exp $
 *
 * Copyright (c) Guido Ludwig. All rights reserved.
 * Use is subject to license terms.
 */

package de.guidoludwig.jtm.domain;

import javax.persistence.Embeddable;

import org.hibernate.annotations.Type;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.FieldBridge;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.annotations.Store;

import com.jgoodies.binding.beans.Model;

import de.guidoludwig.jtm.hibernate.EnumerationBridge;




/**
 * Domain Object for a Location
 * 
 * @author <a href="mailto:jtrade@gigabss.de">Guido Ludwig</a>
 * @version $Revision: 1.9 $
 */
@Embeddable
@Indexed
public class Location extends Model {

	public static final String PROPERTY_VENUE = "venue";

	public static final String PROPERTY_CITY = "city";

	public static final String PROPERTY_STATE = "state";

	public static final String PROPERTY_COUNTRY = "country";

	@Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
	private String venue;

	@Field
	private String city;

	@Field
	private String state;

	@Type(type = "de.guidoludwig.jtm.hibernate.EnumUserType", parameters = @org.hibernate.annotations.Parameter(name = "type", value = "de.guidoludwig.jtm.domain.Country"))
	@Field
	@FieldBridge(impl = EnumerationBridge.class, params = @Parameter(name = "enumType", value = "de.guidoludwig.jtm.domain.Country"))
	private Country country;
	
	public Location() {
//		country = Country.UNKNOWN;
	}

	public String getVenue() {
		return venue;
	}

	public String getCity() {
		return city;
	}

	public String getState() {
		return state;
	}

	public Country getCountry() {
		return country;
	}

	public void setCity(String newValue) {
		String oldValue = city;
		city = (newValue == null ? null : newValue.trim());
		firePropertyChange(PROPERTY_CITY, oldValue, newValue);
	}

	public void setState(String newValue) {
		String oldValue = city;
		state = (newValue == null ? null : newValue.trim());
		firePropertyChange(PROPERTY_STATE, oldValue, newValue);
	}

	public void setCountry(Country newValue) {
		Country oldValue = country;
		country = newValue;
		firePropertyChange(PROPERTY_COUNTRY, oldValue, newValue);
	}

	public void setVenue(String newValue) {
		String oldValue = venue;
		venue = (newValue == null ? null : newValue.trim());
		firePropertyChange(PROPERTY_VENUE, oldValue, newValue);
	}

}
